<div class="form-group">
    <div class="col-md-12">
        <label for="station-type" class="col-md-3 control-label">条件名称<span
                    class="text-danger">*</span></label>
        <div class="col-md-7">
           <input type="text" class="col-md-7" name='name' value='{{$name}}'/>
        </div>
    </div>
</div>
<div class="form-group">
    <div class="col-md-12">
        <label for="station-type" class="col-md-3 control-label">站点类型<span
                    class="text-danger">*</span></label>
        <div class="col-md-7">
            <select class="form-control" id="station_type" name="station_type">
                @foreach(Config::get('app.station_type') as $key => $obj)
                    <option value="{{$key}}" @if($station_type == $key) selected @endif>{{$obj}}</option>
                @endforeach
            </select>
        </div>
    </div>
</div>
<div class="form-group">
    <div class="col-md-12">
        <label for="station-type" class="col-md-3 control-label">设备选择<span
                    class="text-danger">&nbsp;</span></label>
        <div class="col-md-7">
            @foreach(Config::get('app.device_type') as $key => $obj)
                <label class="css-input css-radio css-radio-success push-10-r">
                    <input type="radio" name="device_type" value="{{$key}}"
                           @if($device_type == $key) checked @endif><span></span> {{$obj}}
                </label>
            @endforeach
        </div>
    </div>
</div>
<div class="form-group">
    <div class="col-md-12">
        <label for="page-url" class="col-md-3 control-label">投放区域过滤<span
                    class="text-danger">*</span></label>
        <div class="col-md-7">
            <label class="css-input css-radio css-radio-success push-10-r">
                <input type="radio" name="area_config" value="0" @if($area_config == 0) checked="" @endif><span></span>
                关闭
            </label>

            <label class="css-input css-radio css-radio-success push-10-r">
                <input type="radio" name="area_config" value="2" @if($area_config == 2) checked="" @endif><span></span>
                选择不投放地区
            </label>

        </div>

    </div>
</div>
<div id="area-display" @if($area_config == 0)  style="display: none" @endif>
    <div class="form-group">
        <div class="col-md-12">
            <label class="col-md-3 control-label">不投放地区地区选择<span
                        class="text-danger">&nbsp;</span></label>
            <div class="col-md-7" id="select-area">

            </div>
        </div>
    </div>
    <div class="form-group">
        <div class="col-md-12">
            <label class="col-md-3 control-label">已选不投放地区<span
                        class="text-danger">&nbsp;</span></label>
            <div class="col-md-7" style="white-space:normal; " id="selected-area">

            </div>
        </div>
    </div>
</div>
<div class="form-group">
    <div class="col-md-12">
        <label for="page-url" class="col-md-3 control-label">UserAgent限制<span
                    class="text-danger">*</span></label>
        <div class="col-md-7">
            @foreach(Config::get('app.allow_channel') as $key => $obj)
                <label class="css-input css-checkbox-sm css-checkbox css-checkbox-success push-10-r">
                    <input class="channel" type="checkbox" name="allow{{$key}}" value="{{$key}}"
                           @foreach(explode(',',$channel) as $keyChannel => $objChannel)
                           @if($key == $objChannel) checked @endif
                            @endforeach
                    ><span></span> 允许{{$obj}}中访问
                </label>
            @endforeach
            <input id="channelValue" class="col-md-7" name="channel" value="{{$channel}}"
                   placeholder="格式:QQ,MicroMessenger,NewsArticle,">
        </div>

    </div>
</div>
<div class="form-group">
	<div class="col-md-12">
		<label class="col-md-3 control-label">来源限制<span
					class="text-danger">&nbsp;</span></label>
		<div class="col-md-7" style="white-space:normal; " id="ips">
			 <input id="source" class="col-md-7" name="source" value="{{$source}}"
                   placeholder="格式:baidu.com,qq.com">
		</div>

	</div>
</div>
<div class="form-group">
	<div class="col-md-12">
		<label class="col-md-3 control-label">IP限制<span
					class="text-danger">&nbsp;</span></label>
		<div class="col-md-7" style="white-space:normal; " id="ips">
			<textarea class="col-md-7" name="ips" placeholder="格式:192*118*1*1,192*118*1*255">{{$ips}}</textarea>
		</div>

	</div>
</div>
<div class="form-group">
        <div class="col-md-12">
            <label class="col-md-3 control-label">投放时间<span
                        class="text-danger">&nbsp;</span></label>
            <div class="col-md-7" style="" id="delivery_time">

				<input type="hidden" class='dv col-md-6' name="delivery_time" value='{{$delivery_time}}' readonly="readonly">&nbsp;&nbsp;<label class="css-input css-checkbox-sm css-checkbox css-checkbox-success push-8-r"><input onchange="setDt()" type="checkbox" id="dt_all" @if($delivery_time=='0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23') checked @endif><span></span>全选</label>

				<div style="clear:both;"></div>
				<div >
				@foreach($delivery_times as $dt)
				<label class="css-input css-checkbox-sm css-checkbox css-checkbox-success push-8-r">
						<input class="dt" onchange="delivery({{$dt}})" type="checkbox" value='{{$dt}}' @if(isset($delivery_value[$dt]))checked @endif><span></span>{{$dt}}:00~{{$dt+1}}:00 @if($dt<10) &nbsp;&nbsp;@endif &nbsp;
					</label>
					@if($dt==11)<br/>@endif
				@endforeach
				</div>
            </div>
        </div>
    </div>
<div class="form-group">
    <label for="tagStatus" class="col-md-3 control-label">状态</label>
    <div class="col-md-5">
        <select class="form-control" name="status" id="tagStatus">
            <option value="0" @if ($status === 0) selected="selected" @endif>禁用</option>
			<option value="1" @if ($status === 1) selected="selected" @endif>正常</option>
        </select>
    </div>
</div>
@section('js')
<link rel="stylesheet" href="//as.linwenfa.com/long/css/oneui.css">
    <script src="//as.linwenfa.com/long/js/area.js"></script>
    <script>

        var areas = [{!! $area_list !!}];
        $.areaSelect('#select-area', '#selected-area',areas);
        $(document).ready(function () {
            $('.channel').click(function () {
                var $channelValue = $("#channelValue").val();
                var $newValue = $(this).val() + ',';
                if ($(this).get(0).checked) {
                    $channelValue = $channelValue.replace($newValue, '');
                    $("#channelValue").val($channelValue + $newValue);
                } else {
                    $channelValue = $channelValue.replace($newValue, '');
                    $("#channelValue").val($channelValue);
                }
            });

            $('#station-type').change(function () {
                if ($(this).val() == 2) {
                    $('#weixinInfo').show();
                    $('input[name="allowweixin"]').prop('checked', true);
                } else {
                    $('#weixinInfo').hide();
                    $('input[name="allowweixin"]').prop('checked', false);
                }
            })
            $('#station-type').trigger('change');
        })
        $('input[name="area_config"]').click(function () {
            console.log($(this).val());
            if ($(this).val() != 0) {
                $('#area-display').show();
            } else {
                $('#area-display').css({'display': 'none'});
            }
        });

	//选中时间
	function delivery(value){ 
		var str = '';
		$(".dt:checked").each(function(){
		   str+=this.value+',';
		});
		str=str.substring(0,str.length-1);
		$('.dv').val(str);
	}
	//全选时间
	function setDt(){
		$(".dt").prop("checked",$("#dt_all").is(":checked"));
		delivery(0);
	}
    </script>
    <script src="//as.linwenfa.com/long/js/layer.js"></script>
    <script src="//as.linwenfa.com/long/js/station.editor.js"></script>
	@endsection